<template>
    <div>
        <!-- tab-top-webview-main 顶部滑动条 -->
        <!-- 取消mui-fullscreen类 -->
        <div id="slider" class="mui-slider ">
            <div id="sliderSegmentedControl"
                class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
                <div class="mui-scroll">
                    <a :class="['mui-control-item', item.id==0 ? 'mui-active' : '']" v-for="item in cates"
                        :key="item.id" @tap="getPhotoListByCateId(item.id)">
                        {{item.title}}
                    </a>

                </div>
            </div>

        </div>
        <!-- 图片列表区域 -->
        <ul class="photo-list">
            <router-link v-for="item in list" :key="item.img_url" :to="'/home/photoinfo/'+0" tag="li">
                <img v-lazy="item.img_url">
                <div class="info">
                    <h2 class="info-title">{{item.title}}</h2>
                    <div class="info-body">{{item.descr}}</div>
                </div>
            </router-link>
        </ul>
    </div>

</template>

<script>
    //导入mui组件
    import mui from '../../lib/js/mui.min.js'


    import {
        Toast
    } from 'mint-ui'
    export default {
        data() {
            return {
                newsList: [],
                cates: [], //所有分类的列表数组
                list: []
            }
        },
        mounted() {
            //初始化滑动控件
            mui('.mui-scroll-wrapper').scroll({
                deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
            });
        },
        created() {
            this.getAllCategroy();
            //默认进入图片分享,显示全部的图片列表
            this.getPhotoListByCateId(0);
        },
        methods: {
            getAllCategroy() {

                this.cates = [{
                        title: "全部",
                        id: 0
                    }, {
                        title: "明星美女",
                        id: 1
                    },
                    {
                        title: "明星写真",
                        id: 2
                    }, {
                        title: "清纯甜美",
                        id: 3
                    }, {
                        title: "古典美女",
                        id: 4
                    }, {
                        title: "家具生活",
                        id: 5
                    }, {
                        title: "摄影设计",
                        id: 6
                    }, {
                        title: "摄影学习",
                        id: 7
                    }, {
                        title: "摄影器材",
                        id: 8
                    }
                ]

                // this.$http.get('').then(result=>{

                // })
            },
            getPhotoListByCateId(cateId) {
                this.$http.get('http://60.205.222.7:9980/public/images/data.json').then(result => {
                    if (result.body.status === 0) {
                        this.list = result.body.book;
                    } else {
                        Toast('获取图片列表失败');
                    }
                })
            }
        }
    }
</script>

<style lang="less" scoped>
    * {
        touch-action: pan-x;
    }

    .photo-list {
        list-style: none;
        margin: 0;
        padding: 10px;
        padding-bottom: 0;

        li {
            background-color: #ccc;
            text-align: center;
            margin-bottom: 10px;
            box-shadow: 0 0 9px #999; //边框阴影
            position: relative;
            img {
                width: 100%;
                vertical-align: middle;
            }

            img[lazy=loading] {
                width: 40px;
                height: 300px;
                margin: auto;
            }

            .info {
                color: white;
                text-align: left;
                position: absolute;
                bottom: 0;
                background-color: rgba(0,0,0,0.3);
                max-height: 84px;
                .info-title {
                    font-size: 14px;
                }

                .info-body {
                    font-size: 13px;
                }
            }
        }
    }
</style>